#!/bin/sh

# This is encsrv, a collection of initialization scripts to set up encryption for a web and database server, for the TinyCore Linux Distribution.
#
# Copyright (C) 2015, gabocze
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# To contact the authors of encsrv visit https://gna.org/users/gabocze


# put other system startup commands here

# MySQL
ln -sf /opt/mysql/my.cnf /usr/local/mysql/my.cnf
mkdir /var/run/mysqld
chmod g+w /var/run/mysqld
chown .staff /var/run/mysqld
sudo -u tc /usr/local/mysql/bin/mysqld_safe --socket=/var/run/mysqld/mysqld.sock --pid-file=/var/run/mysqld/mysql.pid 2>&1 > /dev/null &

# Apache
#rm -f /usr/local/apache2/conf/httpd.conf
#ln -sf /opt/apache2/httpd.conf /usr/local/apache2/conf
#ln -sf /opt/apache2/dist.ini /usr/local/apache2/conf/php5/extensions
# Unsuccessfull attemp to get GD working, have better luck than I had.
#sudo ln -s /usr/local/lib/libfreetype.so.6 /usr/lib/libfreetype.so.6
#sudo ln -s /usr/local/lib/libX11.so.6 /usr/lib/libX11.so.6
#sudo ln -s /usr/local/lib/libXpm.so.4 /usr/lib/libXpm.so.4
#sudo ln -s /usr/local/lib/libpng12.so.0 /usr/lib/libpng12.so.0
#sudo ln -s /usr/local/lib/libjpeg.so.62 /usr/lib/libjpeg.so.62
#sudo ln -s /usr/local/lib/libxcb.so.1 /usr/lib/libxcb.so.1
#sudo ln -s /usr/local/lib/libXau.so.6 /usr/lib/libXau.so.6
#sudo ln -s /usr/local/lib/libXdmcp.so.6 /usr/lib/libXdmcp.so.6
#sudo ln -s /usr/local/lib/php/extensions/no-debug-zts-20100525/iconv.so /usr/lib/libiconv.so.2

# Lighttpd
sudo -u tc tce-load -i lighttpd
for v in `ls /usr/local/lib/lighttpd/* | sed 's/.*\/// '`
do
sudo ln -s /usr/local/lib/lighttpd/$v /usr/local/lib/$v
done;
lighttpd -D -f /opt/lighttpd/lighttpd.conf &

